package com.yd.sdk.pay;

import android.app.Activity;
import android.os.Handler;
import android.util.Log;


public class PayManager {

//    private Activity _activity;
    private PayAbstractClass _pay;
    private Handler _handler;
    public PayManager(PayAbstractClass pay) {
//        _activity = activity;
        _pay = pay;
        _handler = new Handler();
    }

    public void Initialized(String ConsumeSku, String NonConsumeSku, String SubsSku)
    {
        _handler.post(new Runnable() {
            public void run() {
                if(_pay != null)
                    _pay.Initialized(ConsumeSku,NonConsumeSku,SubsSku);
                else
                    Log.e("SDK_MAIN","_pay为null");
            }
        });
    }

    public void PurchaseProduct(String productInfo)
    {
        _handler.post(new Runnable() {
            @Override
            public void run() {
                if(_pay != null)
                    _pay.PurchaseProduct(productInfo);
                else
                    Log.e("SDK_MAIN","_pay为null");
            }
        });
    }

    public int GetConnectionState()
    {
        return _pay.GetConnectionState();
    }

    public void QueryPurchaseHistory()
    {
        _handler.post(new Runnable() {
            @Override
            public void run() {
                if(_pay != null)
                    _pay.QueryPurchaseHistory();
                else
                    Log.e("SDK_MAIN","_pay为null");
            }
        });
    }


}
